import { ResponseBodyType, ResponseDetailType } from '@/services/apis/types';
import { Request, Response } from 'express';
import { success } from '../common';

const allData: ResponseBodyType = {
  code: 0,
  type: 'SUCCESS',
  msg: '操作成功',
  data: [
    { id: 34, path: '/admin/api/add', key: 'adminApi::add', name: '接口创建' },
    { id: 39, path: '/admin/api/all', key: 'adminApi::all', name: '接口全部' },
    { id: 38, path: '/admin/api/delete', key: 'adminApi::delete', name: '接口删除' },
    { id: 35, path: '/admin/api/detail', key: 'adminApi::detail', name: '接口详情' },
    { id: 36, path: '/admin/api/edit', key: 'adminApi::edit', name: '接口编辑' },
    { id: 37, path: '/admin/api/enable', key: 'adminApi::enable', name: '接口禁用启用' },
    { id: 33, path: '/admin/api/list', key: 'adminApi::list', name: '接口列表' },
    { id: 18, path: '/admin/menu/add', key: 'adminMenu::add', name: '菜单创建' },
    { id: 22, path: '/admin/menu/delete', key: 'adminMenu::delete', name: '菜单删除' },
    { id: 19, path: '/admin/menu/detail', key: 'adminMenu::detail', name: '菜单详情' },
    { id: 20, path: '/admin/menu/edit', key: 'adminMenu::edit', name: '菜单编辑' },
    { id: 21, path: '/admin/menu/enable', key: 'adminMenu::enable', name: '菜单禁用启用' },
    { id: 17, path: '/admin/menu/list', key: 'adminMenu::list', name: '菜单列表' },
    { id: 41, path: '/admin/menu/mode', key: 'adminMenu::mode', name: '菜单页面权限列表' },
    { id: 24, path: '/admin/menu/pages', key: 'adminMenu::pages', name: '菜单页面列表' },
    { id: 23, path: '/admin/menu/permissions', key: 'adminMenu::permissions', name: '菜单权限' },
    { id: 16, path: '/admin/menu/tree', key: 'adminMenu::tree', name: '菜单树' },
    { id: 26, path: '/admin/permission/add', key: 'adminPermission::add', name: '权限创建' },
    {
      id: 31,
      path: '/admin/permission/addMenuPermissions',
      key: 'adminPermission::addMenuPermissions',
      name: '权限指定菜单批量创建权限',
    },
    {
      id: 32,
      path: '/admin/permission/bindApis',
      key: 'adminPermission::bindApis',
      name: '权限绑定接口',
    },
    { id: 30, path: '/admin/permission/delete', key: 'adminPermission::delete', name: '权限删除' },
    { id: 27, path: '/admin/permission/detail', key: 'adminPermission::detail', name: '权限详情' },
    { id: 28, path: '/admin/permission/edit', key: 'adminPermission::edit', name: '权限编辑' },
    {
      id: 29,
      path: '/admin/permission/enable',
      key: 'adminPermission::enable',
      name: '权限禁用启用',
    },
    { id: 25, path: '/admin/permission/list', key: 'adminPermission::list', name: '权限列表' },
    { id: 9, path: '/admin/role/add', key: 'adminRole::add', name: '角色创建' },
    { id: 40, path: '/admin/role/all', key: 'adminRole::all', name: '角色全部' },
    {
      id: 14,
      path: '/admin/role/bindPermissions',
      key: 'adminRole::bindPermissions',
      name: '角色绑定权限',
    },
    { id: 13, path: '/admin/role/delete', key: 'adminRole::delete', name: '角色删除' },
    { id: 10, path: '/admin/role/detail', key: 'adminRole::detail', name: '角色详情' },
    { id: 11, path: '/admin/role/edit', key: 'adminRole::edit', name: '角色编辑' },
    { id: 12, path: '/admin/role/enable', key: 'adminRole::enable', name: '角色禁用启用' },
    { id: 8, path: '/admin/role/list', key: 'adminRole::list', name: '角色列表' },
    {
      id: 15,
      path: '/admin/role/permissions',
      key: 'adminRole::permissions',
      name: '角色权限列表',
    },
    { id: 2, path: '/admin/user/add', key: 'adminUser::add', name: '账号创建' },
    { id: 7, path: '/admin/user/bindRoles', key: 'adminUser::bindRoles', name: '账号绑定角色' },
    { id: 6, path: '/admin/user/delete', key: 'adminUser::delete', name: '账号删除' },
    { id: 3, path: '/admin/user/detail', key: 'adminUser::detail', name: '账号详情' },
    { id: 4, path: '/admin/user/edit', key: 'adminUser::edit', name: '账号编辑' },
    { id: 5, path: '/admin/user/enable', key: 'adminUser::enable', name: '账号启用禁用' },
    { id: 1, path: '/admin/user/list', key: 'adminUser::list', name: '账号列表' },
  ],
};
const list: ResponseBodyType = {
  code: 0,
  type: 'SUCCESS',
  message: '操作成功',
  data: {
    pageNum: 1,
    pageSize: 10,
    total: 41,
    list: [
      {
        id: 41,
        path: '/admin/menu/mode',
        key: 'adminMenu::mode',
        name: '菜单页面权限列表',
        enabled: false,
        createTime: '2022-08-08 03:18:10',
        modifyTime: '2022-08-08 03:18:10',
      },
      {
        id: 40,
        path: '/admin/role/all',
        key: 'adminRole::all',
        name: '角色全部',
        enabled: true,
        createTime: '2022-08-07 16:26:45',
        modifyTime: '2022-08-07 16:26:45',
      },
      {
        id: 39,
        path: '/admin/api/all',
        key: 'adminApi::all',
        name: '接口全部',
        enabled: true,
        createTime: '2022-08-07 12:40:07',
        modifyTime: '2022-08-07 12:40:07',
      },
      {
        id: 38,
        path: '/admin/api/delete',
        key: 'adminApi::delete',
        name: '接口删除',
        enabled: true,
        createTime: '2022-08-07 12:39:34',
        modifyTime: '2022-08-07 12:39:34',
      },
      {
        id: 37,
        path: '/admin/api/enable',
        key: 'adminApi::enable',
        name: '接口禁用启用',
        enabled: true,
        createTime: '2022-08-07 12:39:23',
        modifyTime: '2022-08-07 12:39:23',
      },
      {
        id: 36,
        path: '/admin/api/edit',
        key: 'adminApi::edit',
        name: '接口编辑',
        enabled: true,
        createTime: '2022-08-07 12:39:10',
        modifyTime: '2022-08-07 12:39:10',
      },
      {
        id: 35,
        path: '/admin/api/detail',
        key: 'adminApi::detail',
        name: '接口详情',
        enabled: true,
        createTime: '2022-08-07 12:38:59',
        modifyTime: '2022-08-07 12:38:59',
      },
      {
        id: 34,
        path: '/admin/api/add',
        key: 'adminApi::add',
        name: '接口创建',
        enabled: true,
        createTime: '2022-08-07 12:38:44',
        modifyTime: '2022-08-07 12:38:44',
      },
      {
        id: 33,
        path: '/admin/api/list',
        key: 'adminApi::list',
        name: '接口列表',
        enabled: true,
        createTime: '2022-08-07 12:38:24',
        modifyTime: '2022-08-07 12:38:24',
      },
      {
        id: 32,
        path: '/admin/permission/bindApis',
        key: 'adminPermission::bindApis',
        name: '权限绑定接口',
        enabled: true,
        createTime: '2022-08-07 12:37:40',
        modifyTime: '2022-08-07 12:37:40',
      },
    ],
  },
};

const detail: ResponseDetailType = {
  code: 0,
  type: 'SUCCESS',
  message: '操作成功',
  data: {
    id: 41,
    path: '/admin/menu/mode',
    key: 'adminMenu::mode',
    name: '菜单页面权限列表',
    describe: '',
    enabled: true,
    createTime: '2022-08-08 03:18:10',
    modifyTime: '2022-08-08 03:18:10',
  },
};

export default {
  'POST /api/admin/api/list': (req: Request, res: Response) => {
    list.data.pageNum = req.body.pageNum;
    list.data.pageSize = req.body.pageSize;
    res.json(list);
  },
  'POST /api/admin/api/add': success,
  'POST /api/admin/api/detail': detail,
  'POST /api/admin/api/edit': success,
  'POST /api/admin/api/enable': success,
  'POST /api/admin/api/delete': success,
  'POST /api/admin/api/all': allData,
};
